package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author dongdong 抖音号：W13883155245
 * @version 1.0
 * @date 2025/8/13
 * @description 阿里云配置类
 */
@Configuration
@Slf4j
public class OssConfiguration {
    @Bean
    @ConditionalOnMissingBean//当没有对象时创建该对象
    public AliOssUtil createOssUtil(AliOssProperties ossProperties) {
        log.info("开始创建阿里云上传工具类对象配置详情{}",ossProperties);
        return new AliOssUtil(ossProperties.getEndpoint(),
                ossProperties.getAccessKeyId(),
                ossProperties.getBucketName(),
                ossProperties.getBucketName());
    }
}
